<?php
class GeneralsController extends AppController{
    var $name = 'Generals';
    var $_sessionVerifyImg = "VerifyImg";
    var $uses = array();
    var $helpers = array("Html");
    function verifyimg(){
        ob_start();
        $code = rand (11111, 99999);
        $this->Session->write($this->_sessionVerifyImg,$code);
        $pathbg="img/bgverifyimg/";
        $arrtextcolor = array(
                    array(77,128,136),
                    array(149,158,170),
                    array(69,69,165),
                    array(136,170,200),
                    array(253,128,203 ),
                    array(93,53,77),
                    array(10,38,59),
                    array(47,115,140)
                );
        $indexbg = rand(0,2);
        $im = imagecreatefrompng($pathbg.$indexbg.".png");
        $bg = imagecolorallocate($im, 0, 0, 0);
        $textcolor = imagecolorallocate($im, $arrtextcolor[$indexbg][0], $arrtextcolor[$indexbg][1], $arrtextcolor[$indexbg][2]);
        $font = imageloadfont('gdfonts/automatic.gdf');
        ob_clean();
        imagestring($im, $font, 10, 8,$code, $textcolor);
        header('Content-type: image/png');
        imagepng($im);
        imagedestroy($im);
        $this->layout =FALSE;
        $this->render(FALSE);
    }
    function viewCode(){
        //$code = $this->Session->read($this->_sessionVerifyImg);
        //echo $code;
        //$this->layout =FALSE;
        //$this->render(FALSE);
    }
}
